package com.flydog.taskManager.controller;

import com.flydog.taskManager.common.api.CommonResult;
import com.flydog.taskManager.common.util.DateUtil;
import com.flydog.taskManager.dto.StatisticResult;
import com.flydog.taskManager.service.StatisticService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;

@RestController
@RequestMapping("/statistic")
@Slf4j
public class StatisticController {

    @Autowired
    StatisticService statisticService;

    @GetMapping("/overview")
    CommonResult<StatisticResult> overviewStatistic(@RequestParam String date) throws Exception{
        Calendar countDate = DateUtil.initDateToStartTimeInDay(date);
        return CommonResult.success(statisticService.CountOverview(countDate));
    }
}
